package org.frvi.goldspring.business.entity;

import org.frvi.goldspring.business.dao.DataObject;

import javax.persistence.*;
import java.util.List;

/**
 * User: Frank
 * Date: Oct 13, 2009
 * Time: 10:52:21 PM
 */
@Entity
@Table(name = "USERS")
@NamedQueries({
        @NamedQuery(name = "user.findByUsername", query = "from User where username = :username")
})
public class User implements DataObject {
    public static final String FIND_BY_USERNAME = "user.findByUsername";

    private Long id;
    private String username;
    private String password;
    private String roles;
    private List<Account> accounts;


    @Id @GeneratedValue
    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(nullable = false, unique = true)
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Column(nullable = false)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getRoles() {
        return roles;
    }

    public void setRoles(String roles) {
        this.roles = roles;
    }


    @OneToMany(mappedBy = "user")
    public List<Account> getAccounts() {
        return accounts;
    }

    public void setAccounts(List<Account> accounts) {
        this.accounts = accounts;
    }
}